﻿using AD.Manage;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web;
using XF.Common;
using XF.Meeting.DAL;
using XF.Meeting.Entity.CommonEntity;
using XF.Meeting.Entity.dbEntity;
using XF.Meeting.Entity.DTO;
using XF.Meeting.Entity.Query;
using XF.Meeting.Service;
using XF.Meeting.Entity.View;
using XF.Meeting.IDal;
using System.Threading;
using XF.Meeting.Api.Common;

namespace test
{
    class Program
    {
        private static readonly string cmsUrl = Convert.ToString(System.Configuration.ConfigurationManager.AppSettings["cmsUrl"]);
        private readonly string apiUser = UCommonWork.Common.Commons.MD5DecodeString(Convert.ToString(System.Configuration.ConfigurationManager.AppSettings["apiUser"]));
        private readonly string apipwd = UCommonWork.Common.Commons.MD5DecodeString(Convert.ToString(System.Configuration.ConfigurationManager.AppSettings["apipwd"]));
        static void Main(string[] args)
        {
            #region   AD同步数据库（user信息）
            //string strSqlConn = UCommonWork.Common.Commons.MD5DecodeString(Convert.ToString(System.Configuration.ConfigurationManager.AppSettings["SQLConnString"]));
            //ADSync sync = new ADSync();
            //var a = sync.ADSyncManage(strSqlConn);
            #endregion
            SettingService service = new SettingService("","");
            UserInfo user = new UserInfo();
            user.ID = 2;
            var a =service.GetOrganizationTreeForOrgcalendarsAuth(user);

            //ConferenceRoomService service = new ConferenceRoomService("","");
            //LoginUser user = new LoginUser();
            //user.IsAdmin = 3;
            //MeetingOrder entity = new MeetingOrder();
            //entity.ID = 9;
            //entity.Begin = "16:45";
            //entity.CRoomIDs = "138,139,";
            //entity.ConferenceTheme = "CESHI";
            //entity.Coordinator = 2;
            //entity.CreatorID = 2;
            //entity.CycleType = 0;
            //entity.Date = "2021-05-19";
            //entity.End = "16:49";
            //entity.HostPerson = 2;
            //entity.MinutesPerson = 2;
            //entity.TimeLength = 2;
            //entity.UserRID = 2;
            //entity.ParticipantIDs = "2,15297,";
            // CInfoQuery query = new CInfoQuery();
            // var a = service.MeetingOrder(user,entity);
            //query.pageIndex = 1;
            //query.pageSize = 12;
            //      var a = service.GetCInfoByID(query);
            //CInfoQuery query = new CInfoQuery();
            //query.CInfoID = 21;
            //var cRoomInfo = service.GetOrgcalendarsByID(query);

            //var (calendarsResult, strerror, calendarsid) = service.InsertCInfoToOrgcalendars(2127);
            //if (calendarsResult)
            //{
            //WeChatHelper wx = new WeChatHelper();
            //wx.InsertWechatSchedule(26);
            // }

            //foreach ( var item in cRoomInfo) 
            //{
            //    try
            //    {
            //        CMSHttpHelper cMS = new CMSHttpHelper();
            //        cMS.SetPassCode(item,out string strError);
            //    }
            //    catch (Exception e )
            //    {

            //        throw e;
            //    }

            //    Console.WriteLine(item.passcode+"---"+item.ConferenceName);
            //}
            //Console.WriteLine(cRoomInfo.Count);
            //GetPassCode(cRoomInfo);
            //Console.ReadKey();
        }
        //public static void GetPassCode(List<CRoomInfo> cRoomInfo) {
        //    var list = cRoomInfo.Select(i => new MeetRooMPIN()
        //    {
        //        CRoomID = i.ID,
        //        Passcode = i.passcode,
        //        cmsGuid = i.CMSGuid
        //    }).ToList();

          
        //    foreach (var item in list)
        //    {
        //        CMSHttpHelper cMS = new CMSHttpHelper();
        //        var lis = cMS.GetPassCode(item, out string strError);
            
        //    }
            
          
        //}
    }
}
